﻿$(window).load(function () {
    count_conversation = 1;

    $("#ContentPlaceHolder1_question_input").keypress(function (event) {
        if (event.keyCode == 13) {
            $("#ContentPlaceHolder1_send").click();
        }
    });

    $("#ContentPlaceHolder1_Button1").click(function () {
        $("#ContentPlaceHolder1_conversation").scrollTop($("#ContentPlaceHolder1_conversation")[0].scrollHeight);
    });

    $("#ContentPlaceHolder1_send").click(function () {
        if (count_conversation % 2 == 0) {
            question('ContentPlaceHolder1_question', $('#ContentPlaceHolder1_question_input').val());
            count_conversation = count_conversation + 1;
        }
        else {
            question('ContentPlaceHolder1_answer', $('#ContentPlaceHolder1_question_input').val());
            count_conversation = count_conversation + 1;
        }
        $("#ContentPlaceHolder1_conversation").scrollTop($("#ContentPlaceHolder1_conversation")[0].scrollHeight);
    });
    function question(type, text) {
        $("#ContentPlaceHolder1_conversation").append('<div id="' + type + '"> ' + text + '</div>');
    }
});
